# _*_ coding utf-8 _*_
# FILENAME：.py
# DESCRIPTION: 配置文件工具类
# AUTH: ZB
# DATE: 2022/6/2 10:00 下午

# 导入模块
import time

"""
计算时间差
入参格式： 2022-01-01 00:00:00
"""
def timedelta(start_time, end_time):
    if (not start_time) or (start_time == 'None') or (not end_time) or (end_time == 'None'):
        return
    # 将其转换为时间数组
    startTimeArray = time.strptime(start_time, "%Y-%m-%d %H:%M:%S")
    endTimeArray = time.strptime(end_time, "%Y-%m-%d %H:%M:%S")
    # 转换为时间戳:
    startTimeStamp = int(time.mktime(startTimeArray))
    endTimeStamp = int(time.mktime(endTimeArray))
    # 计算时间差
    timedelta = endTimeStamp - startTimeStamp
    timedelta_m = (endTimeStamp-startTimeStamp) // 60
    timedelta_s = timedelta - timedelta_m * 60
    return str(timedelta_m) + "分" + str(timedelta_s) + "秒"
